package com.keith.brainmap.collections;

import java.util.ArrayList;
import java.util.List;

/**
 * 进行元素匹配
 * any,只要又一个匹配，返回true
 * all，全部匹配，返回true
 * none，全部不匹配，返回true
 *
 * @author chenli
 * @date 2021-05-21 上午 11:38
 **/
public class MatchStream {
    public static void main(String[] args) {

        List<String> list = new ArrayList<>();
        list.add("周杰伦");
        list.add("王力宏");
        list.add("陶喆");
        list.add("林俊杰");
        boolean anyMatch = list.stream().anyMatch(s -> s.contains("王"));
        System.out.println(anyMatch);
        boolean allMatch = list.stream().allMatch(s -> s.length() > 4);
        System.out.println(allMatch);
        boolean noneMatch = list.stream().noneMatch(s -> s.contains("周"));
        System.out.println(noneMatch);

    }
}
